﻿using Abp.AspNetCore;
using Microsoft.AspNetCore.Builder;

namespace AbpProjectTemplate.Web.Localization
{
    public static class RequestCultureAspNetCoreExtensions
    {
        public static void UseAppRequestLocalization(this IApplicationBuilder app)
        {
            app.UseAbpRequestLocalization(options =>
            {
                //删除默认的AcceptLanguageHeaderRequestCultureProvider
                options.RequestCultureProviders.RemoveAt(4);

                //0 QueryStringRequestCultureProvider  从url加载
                //1 AbpUserRequestCultureProvider  从用户配置加载
                //2 AbpLocalizationHeaderRequestCultureProvider  从.AspNetCore.Culture cookie加载
                //3 CookieRequestCultureProvider  从cookie加载
                //4 AppAcceptLanguageHeaderRequestCultureProvider 从头加载并转换
                options.RequestCultureProviders.Insert(4, new AppAcceptLanguageHeaderRequestCultureProvider(options));
                //6 AbpDefaultRequestCultureProvider
            });
        }
    }
}
